﻿using DevExpress.XtraGrid.Demos.util;
using DiaoPaiDaYin;
using DXApplicationTangche.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.DTO
{
    public class DTO款式配置设计点数据清洗 {
        public String id { get; set; }
        public String styleId { get; set; }
        public String styleNameCN { get; set; }
        public String pItemCD { get; set; }
        public String pItemValue { get; set; }
        public String pItemNameCN { get; set; }
        public String defaultCD { get; set; }
        public String defaultValue { get; set; }
        public String defaultNameCN { get; set; }
        public List<DTO款式配置设计点明细> designPointDetailsDTOs { get => DTO款式配置设计点明细s; set => DTO款式配置设计点明细s = value; }

        private List<DTO款式配置设计点明细> DTO款式配置设计点明细s = new List<DTO款式配置设计点明细>();

        public DTO款式配置设计点数据清洗(DTO款式配置设计点展现 dto)
        {
            this.id = dto.id;
            this.styleId = dto.STYLEID;
            this.styleNameCN = dto.STYLE_NAME_CN;
            this.pItemCD = dto.P_ITEM_CD;
            this.pItemValue = dto.P_ITEM_VALUE;
            this.pItemNameCN = dto.P_ITEM_NAME_CN;
            this.defaultCD = dto.DEFAULT_CD;
            this.defaultValue = dto.DEFAULT_VALUE;
            this.defaultNameCN = dto.DEFAULT_NAME_CN;
            this.designPointDetailsDTOs.Add(new DTO.DTO款式配置设计点明细(dto.C_ITEM_VALUE, dto.C_ITEM_NAME_CN, dto.PICURL, dto.PICN, dto.PIC));
        }
        public DTO款式配置设计点数据清洗 build设计点明细(DTO款式配置设计点展现 dto)
        {
            if (!String.IsNullOrEmpty(dto.DEFAULT_CD) || !String.IsNullOrEmpty(dto.DEFAULT_VALUE) || !String.IsNullOrEmpty(dto.DEFAULT_NAME_CN))
            {
                this.defaultCD = dto.DEFAULT_CD;
                this.defaultValue = dto.DEFAULT_VALUE;
                this.defaultNameCN = dto.DEFAULT_NAME_CN;
            }
            this.designPointDetailsDTOs.Add(new DTO.DTO款式配置设计点明细(dto.C_ITEM_VALUE, dto.C_ITEM_NAME_CN, dto.PICURL, dto.PICN, dto.PIC));
            return this;
        }
    }

    public class DTO款式配置设计点明细
    {
        public String cItemValue { get; set; }
        public String cItemNameCN { get; set; }
        public String picUrl { get; set; }
        public String picN { get; set; }
        //public Image pic { get; set; }
        public DTO款式配置设计点明细(String C_ITEM_VALUE,String C_ITEM_NAME_CN,String PICURL,String PICN, Image PIC)
        {
            this.cItemNameCN = C_ITEM_NAME_CN;
            this.cItemValue = C_ITEM_VALUE;
            //this.pic = PIC;
            this.picN = PICN;
            this.picUrl = PICURL;
        }
    }

    public class DTO款式配置设计点展现 : IComparable<DTO款式配置设计点展现>
    {
        public String id { get; set; }
        public String idd { get; set; }
        public String STYLEID { get; set; }
        public String STYLE_NAME_CN { get; set; }
        public String P_ITEM_CD { get; set; }
        public String P_ITEM_VALUE { get; set; }
        public String P_ITEM_NAME_CN { get; set; }
        public String DEFAULT_CD { get; set; }
        public String DEFAULT_VALUE { get; set; }
        public String DEFAULT_NAME_CN { get; set; }
        public String C_ITEM_VALUE { get; set; }
        public String C_ITEM_NAME_CN { get; set; }
        public String PICURL { get; set; }
        public String PICN { get; set; }
        public Image PIC { get; set; }

        public DTO款式配置设计点展现(DataRow dr)
        {
            this.id = dr["id"].ToString();
            this.idd = dr["idd"].ToString();
            this.STYLEID = dr["STYLEID"].ToString();
            this.STYLE_NAME_CN = dr["STYLE_NAME_CN"].ToString();
            this.P_ITEM_CD = dr["P_ITEM_CD"].ToString();
            this.P_ITEM_VALUE = dr["P_ITEM_VALUE"].ToString();
            this.P_ITEM_NAME_CN = dr["P_ITEM_NAME_CN"].ToString();
            this.DEFAULT_CD = dr["DEFAULT_CD"].ToString();
            this.DEFAULT_VALUE = dr["DEFAULT_VALUE"].ToString();
            this.DEFAULT_NAME_CN = dr["DEFAULT_NAME_CN"].ToString();
            this.C_ITEM_VALUE = dr["C_ITEM_VALUE"].ToString();
            this.C_ITEM_NAME_CN = dr["C_ITEM_NAME_CN"].ToString();
            this.PICURL = dr["PICURL"].ToString();
            this.PICN = dr["PICN"].ToString();
            try
            {
                this.PIC = Image.FromFile(@"pic\" + PICN);
            }
            catch (Exception)
            {
                this.PIC = FunctionHelper.getSSHIRT();
            }
        }

        public DTO款式配置设计点展现(String STYLEID, String P_ITEM_VALUE,String P_ITEM_NAME_CN,String C_ITEM_VALUE,String C_ITEM_NAME_CN,String DEFAULT_FLAG)
        {
            this.STYLEID = STYLEID;
            this.P_ITEM_VALUE = P_ITEM_VALUE;
            this.P_ITEM_NAME_CN = P_ITEM_NAME_CN;
            this.C_ITEM_VALUE = C_ITEM_VALUE;
            this.C_ITEM_NAME_CN = C_ITEM_NAME_CN;
            if (DEFAULT_FLAG != "否")
            {
                this.DEFAULT_CD = P_ITEM_VALUE;
                this.DEFAULT_VALUE = C_ITEM_VALUE;
            }
        }
        public DTO款式配置设计点展现(设计点Excel格式 dto,String styleid,String stylename)
        {
            this.STYLEID = styleid;
            this.STYLE_NAME_CN = stylename;
            this.P_ITEM_VALUE = dto.设计点类型编码;
            this.P_ITEM_NAME_CN = dto.设计点类型;
            this.C_ITEM_VALUE = dto.设计点编码;
            this.C_ITEM_NAME_CN = dto.设计点;
            if (dto.是否默认 != String.Empty)
            {
                this.DEFAULT_CD = this.P_ITEM_VALUE;
                this.DEFAULT_VALUE = this.C_ITEM_VALUE;
                this.DEFAULT_NAME_CN = this.C_ITEM_NAME_CN;
            }
        }
        public int CompareTo(DTO款式配置设计点展现 other)
        {
            if (this.P_ITEM_VALUE != other.P_ITEM_VALUE)
                return 1;
            else if (this.P_ITEM_VALUE == other.P_ITEM_VALUE)
                return 0;
            else
                return -1;
        }
    }
    public class 设计点Excel格式
    {
        public String 设计点类型编码 { get; set; }
        public String 设计点类型 { get; set; }
        public String 设计点编码 { get; set; }
        public String 设计点 { get; set; }
        public String 是否默认 { get; set; }
        public 设计点Excel格式(DataRow dr)
        {
            this.设计点类型编码 = dr["设计点类型编码"].ToString().Trim();
            this.设计点类型 = dr["设计点类型"].ToString().Trim();
            this.设计点编码 = dr["设计点编码"].ToString().Trim();
            this.设计点 = dr["设计点"].ToString().Trim();
            this.是否默认 = dr["是否默认"].ToString().Trim();
        }
        public 设计点Excel格式(DTO款式配置设计点展现 dto, Boolean IfDefault)
        {
            if (IfDefault == true)
            {
                this.是否默认 = "是";
            }
            else { this.是否默认 = ""; }
            this.设计点类型编码 = dto.P_ITEM_VALUE;
            this.设计点类型 = dto.P_ITEM_NAME_CN;
            this.设计点编码 = dto.C_ITEM_VALUE;
            this.设计点 = dto.C_ITEM_NAME_CN;
        }
        public 设计点Excel格式(DataRow dr, int i)
        {
            this.设计点类型编码 = dr["Column0"].ToString().Trim();
            this.设计点类型 = dr["Column1"].ToString().Trim();
            this.设计点编码 = dr["Column2"].ToString().Trim();
            this.设计点 = dr["Column3"].ToString().Trim();
            this.是否默认 = dr["Column4"].ToString().Trim();
        }
        public 设计点Excel格式(StyleDesignExcelDTO dto)
        {
            this.设计点类型编码 = dto.designTypeCode;
            this.设计点类型 = dto.designType;
            this.设计点编码 = dto.designCode;
            this.设计点 = dto.designName;
            if (dto.ifDefault)
            {
                this.是否默认 = "是";
            }
        }
    }
    public class StyleDesignExcelDTO
    {
        public String designTypeCode { get; set; }  //  设计点类型编码
        public String designType { get; set; } //  设计点类型
        public String designCode { get; set; } //  设计点编码
        public String designName { get; set; }   //  设计点
        public Boolean ifDefault { get; set; }//  是否默认
        public StyleDesignExcelDTO()
        {

        }
        public StyleDesignExcelDTO(设计点Excel格式 dto)
        {
            this.designTypeCode = dto.设计点类型编码;
            this.designType = dto.设计点类型;
            this.designCode = dto.设计点编码;
            this.designName = dto.设计点;
            if (!String.IsNullOrWhiteSpace(dto.是否默认))
            {
                this.ifDefault = true;
            }
            else
            {
                this.ifDefault = false;
            }
        }
    }
    /// <summary>
    /// 旧的a_kuanshi_p里的id删除时用
    /// </summary>
    public class DTO旧的款式设计点id
    {
        public String pId { get; set; }
        public String cId { get; set; }
        public DTO旧的款式设计点id()
        {

        }
        public DTO旧的款式设计点id(DTO款式配置设计点展现 dTO)
        {
            this.pId = dTO.id;
            this.cId = dTO.idd;
        }
    }
}
